package com.jm.weibo.logic;

import java.util.List;

import weibo4andriod.Comment;
import weibo4andriod.Trends;

import com.jm.weibo.ui.R;
import com.jm.weibo.util.DateUtil;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListTrendsAdapter extends BaseAdapter {

private LayoutInflater layoutInflater;
	
	private Context context;
	
	public List<Trends> trendsList;
	
	public ListTrendsAdapter(LayoutInflater layoutInflater, Context context,
			List<Trends> trendsList) {
		this.layoutInflater = layoutInflater;
		this.context = context;
		this.trendsList = trendsList;
	}
	
	public ListTrendsAdapter(Context context,
			List<Trends> trendsList) {
		this.context = context;
		this.trendsList = trendsList;
		this.layoutInflater = LayoutInflater.from(context);
	}
    
	public View getView(int position, View convertView, ViewGroup parent) {
	    System.out.println("-------------加载cmtItem----------------");
		View view = layoutInflater.inflate(com.jm.weibo.ui.R.layout.comment_item, null);
		TextView tvItemCmtContent = (TextView) view.findViewById(R.id.tvItemCmtContent);
		
		Trends trends = this.trendsList.get(position);
//		
//		tvItemCmtNickname.setText(trends.getUser().getName());
//		tvItemCmtDate.setText(DateUtil.getCreateAt(trends.getCreatedAt()));
		tvItemCmtContent.setText(trends.getTrends().toString());
//		
		return view;
	}
    
	public int getCount() {
		return this.trendsList.size();
	}

	public Object getItem(int position) {
		return this.trendsList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public void addMoreData(List<Trends> alls) {
		// TODO Auto-generated method stub
		this.trendsList.addAll(alls);
		this.notifyDataSetChanged();
	}
}
